using CustomerContactSystem.Core.Infrastructure.Domain;

namespace CustomerContactSystem.Core.Model {
    public class UserRole : Entity {
        public virtual short Rank { get; set; }
        public virtual string RoleName { get; set; }
        public virtual string RoleDescription { get; set; }

        protected override void Validate() {
            if (Rank == 0) {
                AddBrokenRule(new BusinessRule("Rank", "Rank should be greater than zero!"));
            }

            if (string.IsNullOrEmpty(RoleName)) {
                AddBrokenRule(new BusinessRule("RoleName", "Role name is required!"));
            }

            if (string.IsNullOrEmpty(RoleDescription)) {
                AddBrokenRule(new BusinessRule("RoleDescription", "Role description is required!"));
            }
        }
    }
}